package com.bawei.demo_mvvm.http

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**
 * @author yaotianxue
 * @description
 * @date 2025/1/9
 */
class RetrofitManager {
    companion object{

        fun getRetrofit(): Retrofit {
            var client = OkHttpClient.Builder()
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .connectTimeout(30, TimeUnit.SECONDS)
                .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                .build()
            return Retrofit.Builder()
                .client(client)
                .baseUrl("http://10.161.9.80:7012")
                .addConverterFactory(GsonConverterFactory.create())//自动解析
                .build()
        }

    }
}
